package com.xgc.book.bookserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xgc.book.bookserver.bean.FeedbackBean;
import com.xgc.book.bookserver.mapper.FeedbackMapper;
import com.xgc.book.bookserver.service.FeedbackService;
import com.xgc.book.bookserver.util.ResultJson;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 意见反馈表 服务实现类
 * </p>
 *
 * @author wrz
 * @since 2023-11-20
 */
@Service
@Transactional
public class FeedbackServiceImpl extends ServiceImpl<FeedbackMapper, FeedbackBean> implements FeedbackService {

    @Override
    public ResultJson getPage(int page, int limit, FeedbackBean feedbackBean) {
        IPage<FeedbackBean> iPage = this.page(new Page<>(page, limit),
                new QueryWrapper<FeedbackBean>()
                        .eq(feedbackBean.getUserId() != null, "user_id", feedbackBean.getUserId())
                        .eq(feedbackBean.getAnonymous() != null, "anonymous", feedbackBean.getAnonymous())
                        .eq(feedbackBean.getStatus() != null, "status", feedbackBean.getStatus())
                        .orderByDesc("id"));
        return ResultJson.ok(iPage);
    }
}
